package com.cms.acase.activity

import com.alibaba.android.arouter.facade.annotation.Route
import com.android.baselibrary.arouter.ArouterContains
import com.android.baselibrary.arouter.jumpActivity
import com.android.baselibrary.base.BaseActivity
import com.android.baselibrary.base.BasePath
import com.android.baselibrary.recycler.BaseRecycleViewAdapter
import com.android.baselibrary.recycler.divider
import com.android.baselibrary.recycler.grid
import com.android.baselibrary.utils.GridSpaceItemDecoration
import com.cms.acase.R
import com.cms.acase.bean.CaseMainUtils
import com.cms.acase.databinding.ActivityMainCaseBinding
import com.cms.acase.databinding.ItemGridCaseBinding

/**
 * @author: Mr.You
 * @create: 2023-11-09 13:21
 * @description:实战
 **/
@Route(path = ArouterContains.CASE)
class CaseMainActivity : BaseActivity<ActivityMainCaseBinding>() {
    override fun getLayoutId(): Int = R.layout.activity_main_case

    override fun initView() {
         mBinding.recycleCaseMain.grid(3).divider(margin = 10)
            .adapter = caseAdapter.apply {
            setData(CaseMainUtils.routeData as MutableList<BasePath>)
            setOnItemClickListener { data, _ ->
                jumpActivity(data.path)
            }
        }
        mBinding.recycleCaseMain.addItemDecoration(GridSpaceItemDecoration(3,15))

    }

    override fun initListener() {
    }

    private val caseAdapter = object : BaseRecycleViewAdapter<BasePath, ItemGridCaseBinding>(R.layout.item_grid_case) {
        override fun covert(binding: ItemGridCaseBinding, t: BasePath, position: Int) {
            binding.tvNameCase.text = t.moduleName
        }
    }

}
